Headless hurdles

I was so excited back in the day when Headless was introduced, did some basic tests and waited until I really needed it.
Now I need it and it feels like it is still not 100% there. I was trying to render the basic diamond material from the library, and it seems like the results are a little bit different if I run my script in headless and through Scripting Console in KS UI.

Also, is saving passes and layers in PSD not supported in the headless version?
However, I do feel like the headless is waaay faster in rendering small and fast multiple renders than through KS UI.

Also, I’m getting this error when applying my custom materials with displacement

KShaderNode::pullParameter() Cannot find shader edit for “spectral_ior” on shader “lux_metal”

No idea, but when I use Gold metals from KS Library, I do not have that error. Not sure if it has something to do with displacement.
Any ideas?

I’m a total noob with scripting but I do see this:

setRenderLayer (…)

Associate node with render layer, creating it if name is non-existent. Current render layer will be unset if name is unspecified or empty.
name = Render layer name. (See available ones with lux.getRenderLayers())

So I would say rendering the passes is possible. But like I said, no experience yet using the headless scripting, I can imagine it can be very handy if you need more items or more things rendered fast in a certain way.

No, I know it is there, but it wasn’t in the PSD file after rendering.
I fixed this problem in a weird way:

  • loading the .bip file twice and then importing the 3dm file.
    It seemed like if I only opened bip file once, it would use the rendering settings from the default startup bip file. If I first load my bip file, and then process my ‘bip open - import 3d file’ function it would work normally.

I now have another problem with .setAddToQueue() function. I thought that you can use this function while processing queue, but it looks like that is not the case.

It would make sense to have a queue that you can add to whenever, even if it is processing existing files in the queue. Kind of defeating the purpose otherwise, right?
Maybe I’m just using it in some wrong way.

Your first item seems like a bug, I would open a support ticket for it so they can either fix the bug or maybe give you another solution.

About the render queue, I did file a bug about the queue I noticed when I’ve multiple instances of KeyShot running. Not sure if it’s connected to your experience though.

In my case I was rendering from one Keyshot instance I opened, just normal using GUI. In another KeyShot instance I had another scene and I added stills to the render queue. All looked ok on screen but after that first instance finished the render queue was empty removing the items I put in the queue with the second KS instance.

Hey,
I have filed an improvement request to allow for enabling Multi Layer output to PSDs via scripting. That is indeed not possible at the moment.

In no case though the rendering results from headless should not differ noticably from the headless mode, at least when rendered with sufficient samples for it to resolve.
I suggest to output the rendersettings(lux.getRenderSettings()) and verify they are indeed the same in both cases.

The issue with the Metal Material, the Metal materials have 2 modes they can be in, “Measured” or “Color” i think thats where the culprit lies. But from what i can see thats not a critical error and should not hinder your workflow. Please try in the current beta build, if that error persists.

The Queue:
The queue is not intended to be managed via multiple instances as you described here. So while the Queue is being processed it should not be modified from an other instance since that will create various conflicts.

It is intended to prepare a bulk rendering, to be rendered at a later time when the computer is not in use.

The behavior you expect is more in line with the Network Queue used in KeyShot Network rendering, wich might be more suitible for your purposes.

I hope this could give some insight into this.

actually this sounds exactly as the problem I’m having. The only difference is I’m using headless. Which in this case I don’t think it matters at all.

Thanks for letting me know that you already filed the bug.
I can understand why this happens, there is a .xml file that contains all the .ext files saved in the queue ready for processing, and believe the file might be locked while the queue is being processed (as it updates the xml file everytime one of the renders finishes) and that is why the xml file is not being updated with another KS instance trying to populate the queue.
This shouldn’t be a too big of a problem for luxions programmers to fix

I was thinking I should use the network rendering queue for this then as the queue for that is handled differently, but I don’t like the idea of paying for network rendering while using it locally.

thanks Niko for indepth explanation.

I just noticed your reply, possibly you posted it while I was writing my last reply.

Is there a way to access network rendering with only one local machine? I always liked how network rendering queueing worked, and right now I do not have another machine I could use in network.

I’m experiencing weird problems with rendering animations via headless…

lux.renderAnimation(folder = ‘D:/anim/’, videoName = “”, frameFiles = “frame.%d” + “.jpg”, width = 1000, height = 1000, fps = 30, opts = opts)

In headless I’m getting this error:
AttributeError: module ‘lux’ has no attribute ‘renderAnimation’
[C] Exiting KeyShot due to uncaught Python exception or script failure!

And the same script run from Keyshot script produces this error:
Exception: Please specify a name.

I feel like there might be a bug somewhere?

I have no idea what name I need to specify, I’ve even added videoName to no avail.
Any help?

EDIT:
wait, is renderAnimation not supported in Keyshot headless??? why?

Hey Ivan,

you are correct, you can see what functions are supported in headless scripting here.
Certain functions can not be exposed in headless scripting due to technical reasons that are not easily resolved, and i am afraid this is one of them. I will talk to the team to highlight your request.

As a workaround i suggest you use lux.getAnimationInfo() to get the total frame count and then render each frame via lux.setAnimationFrame() and lux.RenderImage() and when all frames are rendered lux.encodeVideo() to generate the video file.
Note: that this will require you to make sure the fps are set correctly in the file.

Hi Niko,

thanks for your answer.
Yes, that was where I actually learned that it is not available indeed. That is unfortunate.
I did end up making a workaround to rotate the model and run a render, but that produces a lot of entries in the Network Monitor.
Having the frames grouped in one entry like when rendering animations would be great. Other than that, I’m happy with the workaround

Is this fixed in the latest KeyShot version or not? Because if I’m right, lux.renderAnimation is much faster than lux.set.animationFrames .

In the lux.renderAnimation GUI, it’s rendering extremely fast.
But with lux.set.animationFrames , it’s extremely slow, since each frame is rendered individually rather than as part of a continuous animation.